$(function() {
		$(".fied").show();
		$.get('/keyword/getUploadRecord', function(result) {
			var keywordList = result.keywordList;
			for (i = 0; i < keywordList.length; i++) {
				if (keywordList[i].keyword != ""
						&& keywordList[i].keyword != null) {
					var createTime = format(keywordList[i].createTime);
					$('thead#recordTable').append(
							"<tr id=\""+i+"\">" + "<td>" + keywordList[i].id
									+ "</td>" + "<td>"
									+ keywordList[i].campaignName + "</td>"
									+ "<td>" + keywordList[i].adgroupName
									+ "</td>" + "<td>" + keywordList[i].keyword
									+ "</td>" + "<td>" + keywordList[i].price
									+ "</td>" + "<td>" + createTime + "</td>"
									+ "<td>" + keywordList[i].statusDesc
									+ "</td>" + "</tr>");
				}
			}
			$(".fied").hide();
		})
	})
	function format(dateTime) {
		// dateTime是整数，否则要parseInt转换
		var time = new Date(dateTime);
		var y = time.getFullYear();
		var m = time.getMonth() + 1;
		var d = time.getDate();
		var h = time.getHours();
		var mm = time.getMinutes();
		var s = time.getSeconds();
		return y + '-' + add0(m) + '-' + add0(d) + ' ' + add0(h) + ':'
				+ add0(mm) + ':' + add0(s);
	}
	function add0(m) {
		return m < 10 ? '0' + m : m
	}
	function setIfOpen(val) {
	    document.cookie = "ifOpen=" + val;
	  }

	  function getIfOpenVal(param) {
	    var strCookie = document.cookie;
	    var arrCookie = strCookie.split(";");
	    for (var i = 0; i < arrCookie.length; i++) {
	      var arr = arrCookie[i].split("=");
	      if (arr[0] == param)
	        return arr[1];
	    }
	    return null;
	  }
	//收缩服务
	var ifOpen = getIfOpenVal("ifOpen");

	// index页面默认展开浮窗
	if(ifOpen == 0){
	  $(".business-bridge-iframe").animate({
	    left : "-230px",
	  }, 0)
	  $(".js-shrink-button").find("span").removeClass("control").text("服务指导");
	  
	  $(".js-shrink-button").toggle(function() {
	    $(".business-bridge-iframe").animate({
	      left : "0px",
	    }, 1000)
	    $(this).find("span").addClass("control").text("收起");
	    setIfOpen(1);
	  }, function() {

	    $(".business-bridge-iframe").animate({
	      left : "-230px",
	    }, 1000)
	    $(this).find("span").removeClass("control").text("服务指导");
	    setIfOpen(0);
	  })
	}else{

	  $(".js-shrink-button").toggle(function() {
	    $(".business-bridge-iframe").animate({
	      left : "-230px",
	    }, 1000)
	    $(this).find("span").removeClass("control").text("服务指导");
	    setIfOpen(0);
	  }, function() {

	    $(".business-bridge-iframe").animate({
	      left : "0px",
	    }, 1000)
	    $(this).find("span").addClass("control").text("收起");
	    setIfOpen(1);
	  })

	}